/*class A{
    static {
        System.out.println("1");
    }

    {
        System.out.println("2");
    }
    public A(){
        System.out.println("3");
    }
}
class B extends A{
    static {
        System.out.println("4");
    }
    {
        System.out.println("5");
    }
    public B(){
        super();
        System.out.println("6");
    }
}
public class Test {
    public static void main(String[] args) {
        new B();
    }
}
 class Animals{
    public String name;
    public int age;
    public String colour;
    public void A(){
        System.out.println("haha");
    }
}
class cat extends Animals{
    public int a;

    @Override
    public void A() {
        System.out.println("123");
    }
}

class dog extends Animals{
    public String colour;
    public dog(){
        super();
        System.out.println("666");
    }
    public void A(){
        System.out.println("heihei");
    }
    public void get() {
        name = "1";//父类
        age = 2;//父类
        super.colour = "3";//父类
        super.A();//父类
    }
}*/
class Printer{
    public int age;
    public void print(){
        System.out.println("打印文件！");
    }
}

class BlackPrinter extends Printer{
    public String A;
    @Override
    public void print() {
        System.out.println("打印黑白文件！");
    }
}
class ColorPrinter extends Printer{
    public String B;
    @Override
    public void print() {
        System.out.println("打印彩色文件！");
    }
}
public class Test {
    public static void main(String[] args) {
        //向上转型
        Printer printer = new BlackPrinter();
        //向下转型
        BlackPrinter blackPrinter = new BlackPrinter();
        if(printer instanceof BlackPrinter){
            blackPrinter = (BlackPrinter) printer;
        }
    }
    public void print(Printer printer){
        printer.print();
    }
    public static void main1(String[] args) {
        Test test = new Test();
        test.print(new BlackPrinter());
        test.print(new ColorPrinter());
    }
}
